/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright @ Huawei Technologies Co., Ltd. 2024-2024. ALL rights reversed.
 */
#ifndef _LINUX_SYSMONITOR_INOTIFY_H
#define _LINUX_SYSMONITOR_INOTIFY_H
#include <linux/dcache.h>
#include <linux/fsnotify_backend.h>
#include <linux/inotify.h>

#define INOTIFY_IOC_SET_SYSMONITOR_FM   _IO(0xAB, 0xAB)

/*
 * info should be after event, becauce overflow_event is not destroyed by fsnotify_destroy_event
 */
struct inotify_event_process_info {
	int pid;
	int parent_pid;
	char comm[TASK_COMM_LEN];
	char parent_comm[TASK_COMM_LEN];
};

struct inotify_event_info_extend {
	struct inotify_event_info event;
	struct inotify_event_process_info info;
};

int inotify_handle_inode_event_extend(struct fsnotify_mark *inode_mark, u32 mask,
			struct inode *inode, struct inode *dir,
			const struct qstr *name, u32 cookie);

int is_sysmonitor_group(struct fsnotify_group *group);
void free_sysmonitor_group(struct fsnotify_group *group);
int set_sysmonitor_group_flag(struct fsnotify_group *group);

ssize_t copy_event_extend_to_user(struct fsnotify_event *fsn_event,
					char __user *buf, int event_size);
#endif /* _LINUX_SYSMONITOR_INOTIFY_H */
